const fs = require("fs")

function writeFs(path, content) {
    return new Promise((resolve, reject) => {
        fs.writeFile(path, content, {
            flag: 'a',
            encoding: 'utf-8'
        }, err => {
            if (err) {
                reject(err)
            } else {
                resolve(err)
            }
        })
    })
}

function fsRead(url) {
    return new Promise((resolve, reject) => {
        fs.readFile(url, {
            flag: "r",
            encoding: "utf-8"
        }, (err, data) => {
            if (err) reject(err)
            else resolve(data);
        })
    })
}

module.exports = {
    writeFs,
    fsRead
}